// ml:run = $bin < input
#include <iostream>
#include <vector>
#include <string>

int n;

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::string s;
    std::cin >> n >> s;
    s += 'W';
    int now = 0;
    bool last = false;
    std::vector<int> v;
    for (auto ch : s) {
        if (ch == 'B') { now++; last = true; }
        else {
            if (last) { v.push_back(now); last = false; now = 0; }
        }
    }
    std::cout << v.size() << "\n";
    for (auto i : v) std::cout << i << " ";
    std::cout << "\n";
}

